/*
 * VariableSettingTest.cpp
 *
 * Copyright 2012 Fabian Wenzelmann
 *
 * This file is part of Recognition-Procedures-for-Boolean-Functions.
 *
 * Recognition-Procedures-for-Boolean-Functions is free software: you
 * can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * Recognition-Procedures-for-Boolean-Functions is distributed in the hope
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
 * Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Recognition-Procedures-for-Boolean-Functions.
 *
 * If not, see <http://www.gnu.org/licenses/>.
 */

#include <gtest/gtest.h>

#include <vector>

#include "bfr/lpbCombinatorial/VariableSetting.hpp"
#include "bfr/Clause.hpp"
#include "bfr/ClauseSet.hpp"

namespace bfr { namespace test {

TEST(VariableSetting, init) {
	// create test DNF
	Clause *c1 = new Clause(1);
	Clause *c2 = new Clause(2);
	Clause *c3 = new Clause(3);

	ClauseSet *cs = new ClauseSet();

	c1->addSecure(new Literal(0));

	c2->addSecure(new Literal(1));
	c2->addSecure(new Literal(2));

	c3->addSecure(new Literal(1));
	c3->addSecure(new Literal(3));
	c3->addSecure(new Literal(4));

	cs->addSecure(c1);
	cs->addSecure(c2);
	cs->addSecure(c3);

	VariableSetting vs = VariableSetting(cs);

	EXPECT_EQ(0, vs[0]);
	EXPECT_EQ(0, vs.getPos(0));

	EXPECT_EQ(1, vs[1]);
	EXPECT_EQ(1, vs.getPos(1));

	EXPECT_EQ(2, vs[2]);
	EXPECT_EQ(2, vs.getPos(2));

	std::vector<OccurrencePattern*> *occurrences = vs.getOrderedPatterns();
	for(std::vector<OccurrencePattern*>::const_iterator
			it = occurrences->begin();
			it != occurrences->end();
			it++) {
		delete *it;
	}

	delete cs;
	delete occurrences;
}

}}
